package com.afc.struts.utils;

public class Constants
{
  static public Object getDefaultValue(Class aType)
  {
    if (Integer.TYPE.isAssignableFrom(aType))
    {
      return (int)0;
    }
    else if (Short.TYPE.isAssignableFrom(aType))
    {
      return (short)0;
    }
    else if (Long.TYPE.isAssignableFrom(aType))
    {
      return (long)0;
    }
    else if (Double.TYPE.isAssignableFrom(aType))
    {
      return (double)0;
    }
    else if (Float.TYPE.isAssignableFrom(aType))
    {
      return (float)0;
    }
    else if (Character.TYPE.isAssignableFrom(aType))
    {
      return (char)0;
    }
    else if (Boolean.TYPE.isAssignableFrom(aType))
    {
      return false;
    }
    else
    {
      return null;
    }
  }

  static public Class forName(String aName) throws ClassNotFoundException
  {
    if (Integer.TYPE.getName().equals(aName))
    {
      return Integer.TYPE;
    }
    else if (Short.TYPE.getName().equals(aName))
    {
      return Short.TYPE;
    }
    else if (Long.TYPE.getName().equals(aName))
    {
      return Long.TYPE;
    }
    else if (Double.TYPE.getName().equals(aName))
    {
      return Double.TYPE;
    }
    else if (Float.TYPE.getName().equals(aName))
    {
      return Float.TYPE;
    }
    else if (Character.TYPE.getName().equals(aName))
    {
      return Character.TYPE;
    }
    else if (Boolean.TYPE.getName().equals(aName))
    {
      return Boolean.TYPE;
    }
    else
    {
      return Class.forName(aName);
    }
  }
}
